package GUI;

import javafx.application.Application;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.geometry.VerticalDirection;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;


public class JavaFxDemos extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {

        //三大核心概念：Stage,Scene,Node, 其中node包括布局，控件，图形，多媒体等

        //节点初始化
        Text text1 = new Text();
        text1.setFont(new Font(20));
        text1.setText("0");

        Button btn1 = new Button("按钮1");
        btn1.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> {
            int n = Integer.parseInt(text1.getText());
            text1.setText("" + (n+100));
        });

        //布局初始化
        VBox root = new VBox();
        ObservableList list = root.getChildren();
        list.add(btn1);
        list.add(text1);
        //场景初始化
        Scene scene = new Scene(root, 595, 398);
        scene.setFill(Color.LIGHTBLUE);
        //舞台设置
        primaryStage.setScene(scene);
        primaryStage.setTitle("javafx demo");
        primaryStage.show();
    }
}
